<?php
class ProfileForm extends Zend_Form {
    public function __construct($options = null) 
    {
    	$baseurl 		= new MHDEV_View_Helper_BaseUrl();
    	$translation	= Zend_Registry::get('lang');
    	
        parent::__construct($options);
        
        $this->setName('profile_edit');
        
        // Username
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel($translation->_('register_username'));
        $username->setRequired(true);
        $username->setErrorMessages(array(
            0 => $translation->_('error_register_username'),
        ));
        $username->setDescription($translation->_('register_dusername'));
        
        
        // Mail
        $mail = new Zend_Form_Element_Text('mail');
        $mail->setLabel($translation->_('register_mail'));
        $mail->setRequired(true);
        $mail->addFilter('StringToLower');
        $mail->setErrorMessages(array(
            0 => $translation->_('error_register_mail'),
        ));
        $mail->setDescription($translation->_('register_dmail'));
        $mail->addValidator('EmailAddress');

        // Password
        $password = new Zend_Form_Element_Password('password');
		$password->setLabel($translation->_('register_newpassword'));
		$password->setRequired(false);
		$password->addFilter('StringTrim');
		$password->addValidator('StringLength', true, array(6,20));
		$password->setErrorMessages(array(
            'isEmpty' => $translation->_('error_register_password'),
			'stringLengthTooShort' 	=> $translation->_('error_register_password_2'),
            'stringLengthTooLong'	=> $translation->_('error_register_password_3'),
        ));
        $password->setDescription($translation->_('register_dpassword'));

        // language
        $language = new Zend_Form_Element_Select('language');
        $language->setLabel($translation->_('register_language'));
        $language->setDescription($translation->_('register_dlanguage'));
        $language->addMultiOption('en', 'English');
        $language->addMultiOption('de', 'German');
        
        // Forename
        $forename = new Zend_Form_Element_Text('forename');
        $forename->setLabel($translation->_('register_forename'));
        $forename->setRequired(true);
        $forename->setErrorMessages(array(
            0 => $translation->_('error_register_forename'),
        ));
        $forename->setDescription($translation->_('register_dforename'));
        
        // Lastname
        $lastname = new Zend_Form_Element_Text('lastname');
        $lastname->setLabel($translation->_('register_lastname'));
        $lastname->setRequired(true);
        $lastname->setErrorMessages(array(
            0 => $translation->_('error_register_lastname'),
        ));
        $lastname->setDescription($translation->_('register_dlastname'));
        
        // City
        $city = new Zend_Form_Element_Text('city');
        $city->setLabel($translation->_('register_city'));
        $city->setRequired(true);
        $city->setErrorMessages(array(
            0 => $translation->_('error_register_city'),
        ));
        $city->setDescription($translation->_('register_dcity'));
        
        // Zip
        $zip = new Zend_Form_Element_Text('zip');
        $zip->setLabel($translation->_('register_zip'));
        $zip->setRequired(true);
        $zip->setErrorMessages(array(
            0 => $translation->_('error_register_zip'),
        ));
        $zip->setDescription($translation->_('register_dzip'));
        
        // Date of birth
        $dateofbirth = new Zend_Form_Element_Text('date_of_birth');
        $dateofbirth->setLabel($translation->_('register_dateofbirth'));
        $dateofbirth->setRequired(true);
        $dateofbirth->setErrorMessages(array(
            0 => $translation->_('error_register_dateofbirth'),
        ));
        $dateofbirth->setDescription($translation->_('register_ddateofbirth'));
        
        // Homepage
        $homepage = new Zend_Form_Element_Text('homepage');
        $homepage->setLabel($translation->_('register_homepage'));
        $homepage->setRequired(true);
        $homepage->setErrorMessages(array(
            0 => $translation->_('error_register_homepage'),
        ));
        $homepage->setDescription($translation->_('register_dhomepage'));
        
        // signature
        $signature = new Zend_Form_Element_Textarea('signature');
		$signature->setLabel($translation->_('register_signature'));
		$signature->setDescription($translation->_('register_dsignature'));
		$signature->addFilter('StringTrim');
		$signature->setAttrib('rows','5');
		$signature->setAttrib('cols','30');
		$signature->setErrorMessages(array(
            0 => $translation->_('register_error_signature'),
        ));
        
        // Threads per page
        $threadspp = new Zend_Form_Element_Select('threads_per_page');
        $threadspp->setLabel($translation->_('register_threadspp'));
        $threadspp->setDescription($translation->_('register_dthreadspp'));
        $threadspp->addMultiOption('10', '10');
        $threadspp->addMultiOption('20', '20');
        $threadspp->addMultiOption('50', '50');
        $threadspp->addMultiOption('100', '100');
        $threadspp->setDescription($translation->_('register_dthreadspp'));
        
        // Posts per page
        $postspp = new Zend_Form_Element_Select('posts_per_page');
        $postspp->setLabel($translation->_('register_postspp'));
        $postspp->addMultiOption('10', '10');
        $postspp->addMultiOption('20', '20');
        $postspp->addMultiOption('50', '50');
        $postspp->addMultiOption('100', '100');
        $postspp->setDescription($translation->_('register_dpostspp'));
		
		// Posts rating
		$rating = new Zend_Form_Element_Text('posts_rating');
		$rating->setLabel($translation->_('register_postrating'));
		$rating->setRequired(true);
		$rating->setErrorMessages(array(
			0 => $translation->_('error_register_postrating'),
		));
		$rating->setDescription($translation->_('register_dpostrating'));

		// layout
		$layout	= new Zend_Form_Element_Select('layout');
		$layout->setRegisterInArrayValidator(false);
		$layout->setLabel($translation->_('register_layout'));
		$layout->setDescription($translation->_('register_dlayout'));
		
		// Submit
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel($translation->_('form_save'));
		
		$this->addElements(array(
			$forename, $lastname, $username, 
			$dateofbirth, $city, $zip, 
			$mail, $homepage, $language, 
			$signature, $threadspp, $postspp, $rating, 
			$layout, $password, $submit
		));
    }
}  
?>